package com.xl.basic.controller;

import com.xl.basic.annotation.RoleValidated;
import com.xl.basic.entity.Result;
import com.xl.basic.entity.UserInfo;
import com.xl.basic.entity.param.AddOrUpdRoleMenuParam;
import com.xl.basic.service.RoleMenuService;
import com.xl.basic.utils.LoginUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 钟勇
 * Create in 2023/8/31 10:19
 */

@Tag(name = "角色菜单管理")
@RestController
@RequestMapping("/api/RoleMenu")
@RequiredArgsConstructor
@RoleValidated
public class RoleMenuController {
    private final RoleMenuService roleMenuService;


    @Operation(summary = "添加或者编辑角色菜单")
    @PostMapping(value = "/addOrUpdRoleMenu")
    Result<Object> addOrUpdRoleMenu(@Validated AddOrUpdRoleMenuParam param) {
        Result<UserInfo> userInfoResult = LoginUtils.getUserInfo();
        return roleMenuService.addOrUpdRoleMenu(param, userInfoResult.getResult());
    }
}
